@ECHO OFF


REM afti-2013-oop-nsu.googlecode.com

SET SvnDir=%APPDATA%\Subversion\auth\svn.simple
SET ProjectName=afti-2013-oop-nsu.googlecode.com
SET UserName=

SET FileName=

IF NOT EXIST "%SvnDir%" EXIT /B 0

PUSHD "%SvnDir%"
	DIR /B/A-D "*" >nul 2>&1 && (
		FOR /F "tokens=*" %%F IN ('DIR /B/A-D "*"') DO (
			IF "%FileName%"=="" (
				FIND /i "%ProjectName%" "%%F" >nul 2>&1 && (
					IF NOT "%UserName%"=="" (
						FIND /i "%UserName%" "%%F" >nul 2>&1 && (
							SET FileName="%SvnDir%\%%F"
						)
					) ELSE (
						SET FileName="%SvnDir%\%%F"
					)
				)
			)
		)
	)
POPD

IF "%FileName%"=="" (
	IF "%UserName%"=="" (
		ECHO Svn auth record for project %ProjectName% was not found.
	) ELSE (
		ECHO Svn auth record for project %ProjectName%, user %UserName% was not found.
	)
	PAUSE
) ELSE (
	XCOPY /Y /C "%FileName%" "." >nul 2>&1
)

EXIT /B 0